// eee.Sheffield.PZ.Imaging
//
// Copyright ?Ping Zou, 2007
// sg71.cherub@gmail.com

using System;
using System.Collections.Generic;
using System.Text;
using eee.Sheffield.PZ.Math;
using System.Drawing;
using System.Drawing.Imaging;

namespace eee.Sheffield.PZ.Imaging.ImageFilter
{
    public class ReduceResolution : ImageFilter//, IGraylevelImageFilter
    {
        #region Fields
        //private string flag = "[Image -> Reduce Resolution]";
        #endregion

        #region Constructor
        public ReduceResolution()
        {
            _flag = "[Image -> Reduce Resolution]";
        }
        #endregion

        //#region Properties
        //public string Flag() { return flag; }
        //public string Log() { return _log; }
        //#endregion

        #region Apply filter
        //public Bitmap ApplyGraylevelImageFilter(Bitmap srcImage) { return Apply(srcImage, out _log); }
        //public PZMath_matrix ApplyDoubleGraylevelImageFilter(PZMath_matrix srcMatrix) { return ApplyDouble(srcMatrix, out _log); }

        //private Bitmap Apply(Bitmap srcImage, out string logText)
        //{
        //    //srcImage.Save("srcImgae.bmp", ImageFormat.Bmp);
        //    PZMath_matrix srcMatrix = _converter.ConvertGraylevelBitmapToMatrix(srcImage);
        //    PZMath_matrix dstMatrix = ApplyDouble(srcMatrix, out logText);
        //    Bitmap dstImage = _converter.ConvertMatrixToGraylevelBitmap(dstMatrix);
        //    //dstImage.Save("dstimage.bmp", ImageFormat.Bmp);
        //    return dstImage;
        //}

        protected override PZMath_matrix ApplyDoubleGraylevelImageFilter(PZMath_matrix srcMatrix, out string logText)
        {
            // 2D gaussian kernel
            PZMath_matrix kernel = Kernel.GaussianKernel2D(1);
            PZMath_matrix dstMatrix = srcMatrix.Reduce(kernel);
            logText = "succeeds.";
            return dstMatrix;
        } // ApplyDoubleGraylevelImageFilter()

        protected override PZMath_matrix[] ApplyDoubleColourImageFilter(PZMath_matrix[] srcMatrixArray, out string logText)
        {
            // TODO: add this function
            
            throw new Exception("The method or operation is not implemented.");
        } // ApplyDoubleColourImageFilter()
        #endregion
    }
}
